package com.zhan.easyexcelorder.model;

import com.zhan.jpa.model.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Set;

@Entity
@Table(name = "sys_user")
@Cacheable
@org.hibernate.annotations.Cache(usage = CacheConcurrencyStrategy.READ_WRITE, region = "entityCache")
@Data
public class SysUser extends BaseEntity implements java.io.Serializable {
    private static final long serialVersionUID = -8419060804847492359L;

    @ApiModelProperty("用户名")
    private String username;
    @ApiModelProperty("密码")
    private String password;
    @ApiModelProperty("手机号")
    private String phone;
    @ApiModelProperty(value = "性别，0-男，1-女", allowableValues = "0,1")
    private Integer sex;
    @ApiModelProperty("上班普席工号")
    private String generalCode;
    @ApiModelProperty("抢班普席工号")
    private String snatchCode;
    @ApiModelProperty("密码状态（0-未修改密码，1-以修改密码）")
    private Integer passwordState = 0;
    @ApiModelProperty("设备token（推送使用）")
    private String deviceToken;
    @ApiModelProperty("设备类型（0-Android，1-iOS，99-其他）")
    private Integer deviceType;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "department_id", unique = true)
    private SysDepartment department;

//    @ApiModelProperty("部门id")
//    private Long departmentId;
//    @ApiModelProperty("部门名称")
//    private String departmentName;
//    @ApiModelProperty("部门全称 （格式-/部门1/部门2/.../部门n)")
//    private String fullDepartmentName;

    @ApiModelProperty("登录时间")
    private Date loginTime;
    @ApiModelProperty(value = "状态（0-正常，1-禁用，99-其他）", allowableValues = "0,1,99")
    private Integer userState;
    @ApiModelProperty("排序字段")
    private Integer sortCount;

    @ManyToMany(fetch = FetchType.EAGER)
    @JoinColumn(name = "id")
    private Set<SysRole> roles;

    @Transient
    private List<String> operationCodeList;

}
